
#include "mstring.h"

namespace mdkl{
void str_replace_all(string& source,char* find,char* rep)
{
	string::size_type pos = 0;       
	string::size_type findlen = strlen(find);
	string::size_type replen = strlen(rep);
	while((pos = source.find(find,pos)) != string::npos)
	{                
		source.replace(pos,findlen,rep);                
		pos += findlen-replen;        
	}
}
	
void str_replace_all(wstring& source,wchar_t* find,wchar_t* rep)
{
	wstring::size_type pos = 0;       
	wstring::size_type findlen = wcslen(find);
	wstring::size_type replen = wcslen(rep);
	while((pos = source.find(find,pos)) != wstring::npos)
	{                
		source.replace(pos,findlen,rep);                
		pos += findlen - replen;        
	}
}
}